import requests
#获取1级清单
def getPlayList():
    url = 'http://api.vipmisss.com:81/xcdsw/json.txt'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',

        'Connection': 'keep-alive',
    }
    html = requests.get(url=url, headers=headers)
    JSON = html.json()
# html.headers #获得请求的头部信息
# html.url     #获得请求的url
# html.text    #获得请求的数据以字符串显示
# html.content #获得请求的数据以二进制显示
# html.json()  #如果直接就返回的是json格式可以用json()直接转换成dict
    list = html.json()['pingtai']
    # print(list)
    items = []
    for i in list:
        # print(i)
        # 1初始化init

        # 2这里添加赋值操作
        address = ''
        xinimg = ''
        Number = ''
        title = ''
        item = {
            'address': i['address'],
            'img': i['xinimg'],
            'Number': i['Number'],
            'title': i['title'],
        }
        # 3 append是加入到list
        items.append(item)

    return items

#根据关键词获取二级清单
def getPlay(address):
    url = f"http://api.maiyoux.com:81/mf/{address}"
    print(url)
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',

        'Connection': 'keep-alive',
    }
    html = requests.get(url=url, headers=headers)
    JSON = html.json()
    print(JSON)
    list = html.json()['zhubo']
    return list

